#ifndef XIMEA_H
#define XIMEA_H

#include <QThread>
#include <QDebug>
#include <m3api/xiApi.h>
#include <memory.h>
#include <QTimer>
#include <QVector>
#include <QRgb>
#include <QProcess>
#include "save.h"
#include "gpio.h"
#include "lux.h"

#define HandleResult(res,place) if (res!=XI_OK) {printf("Error after %s (%d)\n",place,res);}
#define VIDEO 0


class Ximea : public QThread
{
    Q_OBJECT
public:
    explicit Ximea(int exp, double gai, QObject *parent = 0);
    ~Ximea();

signals:
    void readImageSignal();
    void deviceTypeSignal(QString s);
    void ximeaokSignal();
    void ximeastartSignal();

private slots:
    void timerOutSlot();
    void exposureSlot(int exp);
    void gainSlot(double gai);
    void shotSlot();
    void ximeaokSlot();

protected:
    void run();

private:
    HANDLE xiH;
    XI_RETURN stat;
//    QTimer *qtimer;
    DWORD ximea_number;
    bool ximea_stat;

    int exposure = 1500;
    double gain = 1.0;
    QVector<QRgb> qVector;
    Save *sa;
    lux V30D;

};

#endif // XIMEA_H
